package com.kkarma.controller;

import com.kkarma.service.LoginService;
import com.kkarma.util.ResponseWrapper;
import com.kkarma.vo.LoginBody;
import com.kkarma.vo.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: karma
 * @Date: 2022/3/30 0030 - 03 - 30 - 11:58
 * @Description: controller
 * @version: 1.0
 */
@RestController
public class LoginController {

    private final LoginService loginService;

    @Autowired
    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }


    @PostMapping("/login")
    public ResponseWrapper login(@RequestBody LoginBody loginBody) {
        ResponseWrapper rw = ResponseWrapper.success();
        String token = loginService.login(loginBody);
        rw.put("token", token);
        return rw;
    }
}
